<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>显示隐藏密码</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }
        
        body {
            /* background: #DADBDC; */
            position: relative;
        }
        
        .wrap {
            position: fixed;
            top: 0px;
            left: 0px;
            width: 100%;
            height: 100%;
            background: url('./img/02.jpg') no-repeat;
            background-size: cover;
            background-position: center center;
            z-index: -999;
            min-width: 800px;
            min-height: 450px;
        }
        
        #box {
            position: absolute;
            /* margin: 0 auto; */
            /* margin-top: 167.576px; */
            width: 640px;
            height: 350px;
            background: #fff;
            border-radius: 15px;
            text-align: center;
        }
        
        .input_container {
            width: 290px;
            height: 38px;
            background: #fff;
            /* border: none; */
            line-height: 38px;
            font-size: 16px;
            padding-left: 30px;
        }
        
        .input_img {
            position: relative;
            top: 16px;
            left: -11px;
        }
        
        #eyes {
            position: relative;
            top: -30px;
            left: 133px;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <div id="box">
            <H1>登录</H1>
            <br>
            <span style="text-align: center; color: #F87878;">请先登录以管理路由器</span>
            <br>
            <br>
            <img class="input_img" id="account_img" src="./img/account.jpg" height="38px" alt="">
            <input class="input_container" type="text" name="account" id="account" placeholder="请输入用户名" autocomplete="off">
            <br>
            <br>
            <img class="input_img" id="account_img" src="./img/authText.jpg" height="38px" alt="">
            <input class="input_container" type="password" name="authText" id="authText" placeholder="请输入密码" autocomplete="off">
            <br>
            <label for="authText" id="eyes"><img id="eyes_img" src="./img/close_eys.jpg" alt="" height="19px"></label>
        </div>
    </div>
</body>

</html>

<script>
    window.addEventListener('DOMContentLoaded', function(e) {
        // 获取页面元素
        let authText = window.document.querySelector('#authText');
        let eyes_img = window.document.querySelector('#eyes_img');
        // 页面元素绑定事件
        eyes_img.onclick = function() {
            let type = authText.type;
            // window.console.log(type);
            switch (type) {
                case 'text':
                    // 修改页面元素属性
                    authText.type = 'password';
                    eyes_img.src = './img/close_eys.jpg';

                    break;
                case 'password':

                    // 修改页面元素属性
                    authText.type = 'text';
                    eyes_img.src = './img/open_eys.jpg';
                    break;

                default:
                    break;
            }
        };
        formPos();
    });
    window.addEventListener('resize', formPos);

    function formPos(e) {
        let innerWidth = window.innerWidth;
        let innerHeight = window.innerHeight;
        let box = window.document.querySelector('#box');
        let x = (innerWidth - 640) / 2;
        let y = (innerHeight - 350) / 2;
        box.style.position = 'absolute';
        box.style.top = y + 'px';
        box.style.left = x + 'px';
    }
</script>